﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Xuhengxiao.MyDataStructure;
using System.Collections;

namespace Xuhengxiao.MediaConverter
{
    
    [Serializable]
     public  class clsXmlAppConfig
    {
        //用ArrayList主要是为了方便添加删除，但这个有些破坏封装。

        

        /// <summary>
        /// 格式参数的配置
        /// </summary>
        [XmlArray]
        [XmlArrayItem(Type = typeof(clsParameterOptionScheme))]
        public ArrayList arrlistParameterOptionSchemes=new ArrayList();

        /// <summary>
        /// 这个就是配置了
        /// </summary>
        [XmlArray]
        [XmlArrayItem(Type = typeof(clsParameter))]
        public ArrayList arrlistParameters=new ArrayList();

        public clsXmlAppConfig()
        {
            init();//这个只是在没有配置的时候定义一个配置
        }



        /// <summary>
        /// 初始化
        /// </summary>
        public void init()
        {

            #region 定义各个格式的选项
            //3GP
            clsParameterOptionScheme clsParameterOptionScheme1 = new clsParameterOptionScheme();
            clsParameterOptionScheme1.FormatName = "3gp";
            clsParameterOptionScheme1.SSize = new clsParameterOptionSchemeItem(new string[] { "128x96", "176x144", "320x240", "704x576", "1408x1152" }, false);
            clsParameterOptionScheme1.AcChannels = new clsParameterOptionSchemeItem(new string[] { "1" }, true);
            clsParameterOptionScheme1.AcodecCodec = new clsParameterOptionSchemeItem(new string[] { "libopencore_amrnb", "aac -strict experimental" }, false);
            clsParameterOptionScheme1.ArFreq = new clsParameterOptionSchemeItem(new string[] { "8000" }, false);
            clsParameterOptionScheme1.AbBitrate = new clsParameterOptionSchemeItem(new string[] { "12.2k","10.2k","7.95k","7.4k","6.7k","5.9k","5.15k","4.75k" }, false);
            clsParameterOptionScheme1.BBitrate= new clsParameterOptionSchemeItem(new string[] { "128k" }, true);
            clsParameterOptionScheme1.RFps = new clsParameterOptionSchemeItem(new string[] { "9","10","12","15","18" }, true);
            clsParameterOptionScheme1.AspectAspect = new clsParameterOptionSchemeItem(new string[] { "auto", "4:3", "16:9", "1.3333:1.7777" }, false);
            clsParameterOptionScheme1.BtTolerance = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.MaxrateBitrate = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.MinrateBitreate = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.BufsizeSize = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.VcodecCodec = new clsParameterOptionSchemeItem(new string[] { "auto", "h263" }, false);
            //将定义的格式配置添加到这里
            arrlistParameterOptionSchemes.Add(clsParameterOptionScheme1);

            //3g2
            clsParameterOptionScheme1 = new clsParameterOptionScheme();
            clsParameterOptionScheme1.FormatName = "3g2";
            clsParameterOptionScheme1.SSize = new clsParameterOptionSchemeItem(new string[] { "128x96", "176x144", "320x240", "704x576", "1408x1152" }, false);
            clsParameterOptionScheme1.AcChannels = new clsParameterOptionSchemeItem(new string[] { "1" }, true);
            clsParameterOptionScheme1.AcodecCodec = new clsParameterOptionSchemeItem(new string[] { "libopencore_amrnb", "aac -strict experimental" }, false);
            clsParameterOptionScheme1.ArFreq = new clsParameterOptionSchemeItem(new string[] { "8000" }, false);
            clsParameterOptionScheme1.AbBitrate = new clsParameterOptionSchemeItem(new string[] { "12.2k", "10.2k", "7.95k", "7.4k", "6.7k", "5.9k", "5.15k", "4.75k" }, false);
            clsParameterOptionScheme1.BBitrate = new clsParameterOptionSchemeItem(new string[] { "128k" }, true);
            clsParameterOptionScheme1.RFps = new clsParameterOptionSchemeItem(new string[] { "9", "10", "12", "15", "18" }, true);
            clsParameterOptionScheme1.AspectAspect = new clsParameterOptionSchemeItem(new string[] { "auto", "4:3", "16:9", "1.3333:1.7777" }, false);
            clsParameterOptionScheme1.BtTolerance = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.MaxrateBitrate = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.MinrateBitreate = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.BufsizeSize = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.VcodecCodec = new clsParameterOptionSchemeItem(new string[] { "auto", "h263", "libx264 -qmin 10 -qmax 51 -qdiff 4 -me_range 16 -keyint_min 25 -qcomp 0.6" }, false);
            //将定义的格式配置添加到这里
            arrlistParameterOptionSchemes.Add(clsParameterOptionScheme1);

            //mp3
            clsParameterOptionScheme1 = new clsParameterOptionScheme();
            clsParameterOptionScheme1.FormatName = "mp3";
            clsParameterOptionScheme1.SSize = new clsParameterOptionSchemeItem(new string[] { }, false);
            clsParameterOptionScheme1.AcChannels = new clsParameterOptionSchemeItem(new string[] { "1" }, true);
            clsParameterOptionScheme1.AcodecCodec = new clsParameterOptionSchemeItem(new string[] { "libmp3lame" }, false);
            clsParameterOptionScheme1.ArFreq = new clsParameterOptionSchemeItem(new string[] { "11025","22050","44100" }, false);
            clsParameterOptionScheme1.AbBitrate = new clsParameterOptionSchemeItem(new string[] { "128k", "192k", "256k", "320k" }, true);
            clsParameterOptionScheme1.BBitrate = new clsParameterOptionSchemeItem(new string[] {}, false);
            clsParameterOptionScheme1.RFps = new clsParameterOptionSchemeItem(new string[] {  }, false);
            clsParameterOptionScheme1.AspectAspect = new clsParameterOptionSchemeItem(new string[] {}, false);
            clsParameterOptionScheme1.BtTolerance = new clsParameterOptionSchemeItem(new string[] { }, false);
            clsParameterOptionScheme1.MaxrateBitrate = new clsParameterOptionSchemeItem(new string[] { }, false);
            clsParameterOptionScheme1.MinrateBitreate = new clsParameterOptionSchemeItem(new string[] { }, false);
            clsParameterOptionScheme1.BufsizeSize = new clsParameterOptionSchemeItem(new string[] { }, false);
            clsParameterOptionScheme1.VcodecCodec = new clsParameterOptionSchemeItem(new string[] {  }, false);
            //将定义的格式配置添加到这里
            arrlistParameterOptionSchemes.Add(clsParameterOptionScheme1);

            //mp4
            clsParameterOptionScheme1 = new clsParameterOptionScheme();
            clsParameterOptionScheme1.FormatName = "mp4";
            clsParameterOptionScheme1.SSize = new clsParameterOptionSchemeItem(new string[] { "128x96", "176x144", "320x240" }, false);
            clsParameterOptionScheme1.AcChannels = new clsParameterOptionSchemeItem(new string[] { "1","2" }, true);
            clsParameterOptionScheme1.AcodecCodec = new clsParameterOptionSchemeItem(new string[] { "libmp3lame", "libopencore_amrnb", "aac -strict experimental" }, false);
            clsParameterOptionScheme1.ArFreq = new clsParameterOptionSchemeItem(new string[] { "11025", "22050", "44100" }, false);
            clsParameterOptionScheme1.AbBitrate = new clsParameterOptionSchemeItem(new string[] {"96k", "128k", "192k", "256k", "320k" }, true);
            clsParameterOptionScheme1.BBitrate = new clsParameterOptionSchemeItem(new string[] { "128k", "192k", "256k", "512k","768k","1024k" }, true);
            clsParameterOptionScheme1.RFps = new clsParameterOptionSchemeItem(new string[] { "9", "10", "12", "15", "18" }, false);
            clsParameterOptionScheme1.AspectAspect = new clsParameterOptionSchemeItem(new string[] { "auto", "4:3", "16:9", "1.3333:1.7777" }, false);
            clsParameterOptionScheme1.BtTolerance = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.MaxrateBitrate = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.MinrateBitreate = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.BufsizeSize = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.VcodecCodec = new clsParameterOptionSchemeItem(new string[] { "auto", "libxvid", "libx264 -qmin 10 -qmax 51 -qdiff 4 -me_range 16 -keyint_min 25 -qcomp 0.6" }, true);
            //将定义的格式配置添加到这里
            arrlistParameterOptionSchemes.Add(clsParameterOptionScheme1);

            //flv
            clsParameterOptionScheme1 = new clsParameterOptionScheme();
            clsParameterOptionScheme1.FormatName = "flv";
            clsParameterOptionScheme1.SSize = new clsParameterOptionSchemeItem(new string[] { "128x96", "176x144", "320x240" }, false);
            clsParameterOptionScheme1.AcChannels = new clsParameterOptionSchemeItem(new string[] { "1", "2" }, true);
            clsParameterOptionScheme1.AcodecCodec = new clsParameterOptionSchemeItem(new string[] {}, false);
            clsParameterOptionScheme1.ArFreq = new clsParameterOptionSchemeItem(new string[] { "11025", "22050", "44100" }, false);
            clsParameterOptionScheme1.AbBitrate = new clsParameterOptionSchemeItem(new string[] {  }, true);
            clsParameterOptionScheme1.BBitrate = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.RFps = new clsParameterOptionSchemeItem(new string[] { "9", "10", "12", "15", "18" }, false);
            clsParameterOptionScheme1.AspectAspect = new clsParameterOptionSchemeItem(new string[] { "auto", "4:3", "16:9", "1.3333:1.7777" }, false);
            clsParameterOptionScheme1.BtTolerance = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.MaxrateBitrate = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.MinrateBitreate = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.BufsizeSize = new clsParameterOptionSchemeItem(new string[] { }, true);
            clsParameterOptionScheme1.VcodecCodec = new clsParameterOptionSchemeItem(new string[] {  }, true);
            //将定义的格式配置添加到这里
            arrlistParameterOptionSchemes.Add(clsParameterOptionScheme1);

            #endregion


            #region  定义各个配置

            clsParameter clsParameter1 = new clsParameter();
            clsParameter1.FormatName = "3gp";
            clsParameter1.ParameterName = "3gp格式GSM手机";
            clsParameter1.SSzie = "176x144";
            clsParameter1.AcChannels = "1";
            clsParameter1.AcCodecCodec = "libopencore_amrnb";
            clsParameter1.ArFreq = "8000";
            clsParameter1.AbBitRate = "12.2k";
            clsParameter1.BBitRate = "128k";
            clsParameter1.RFps = "15";

            clsParameter1.isAC = true;
            clsParameter1.isVn = true;
            //将定义的配置添加到这里
            arrlistParameters.Add(clsParameter1);


             clsParameter1 = new clsParameter();
            clsParameter1.FormatName = "3g2";
            clsParameter1.ParameterName = "3g2格式CDMA手机";
            clsParameter1.SSzie = "176x144";
            clsParameter1.AcChannels = "1";
            clsParameter1.AcCodecCodec = "libopencore_amrnb";
            clsParameter1.ArFreq = "8000";
            clsParameter1.AbBitRate = "12.2k";
            clsParameter1.BBitRate = "128k";
            clsParameter1.RFps = "15";

            clsParameter1.isAC = true;
            clsParameter1.isVn = true;
            //将定义的配置添加到这里
            arrlistParameters.Add(clsParameter1);

            clsParameter1 = new clsParameter();
            clsParameter1.FormatName = "mp4";
            clsParameter1.ParameterName = "mp4";
            clsParameter1.SSzie = "320x240";
            clsParameter1.AcChannels = "2";
            clsParameter1.AcCodecCodec = "aac -strict experimental";
            clsParameter1.ArFreq = "44100";
            clsParameter1.AbBitRate = "128k";
            clsParameter1.BBitRate = "512k";
            clsParameter1.RFps = "24";
            clsParameter1.VCodecCodec = "libxvid";

            clsParameter1.isAC = true;
            clsParameter1.isVn = true;
            //将定义的配置添加到这里
            arrlistParameters.Add(clsParameter1);


            clsParameter1 = new clsParameter();
            clsParameter1.FormatName = "flv";
            clsParameter1.ParameterName = "flv格式,不推荐转换成这种格式，耗资源，但很多博客用的是这种。";
            clsParameter1.SSzie = "320x240";
            clsParameter1.AcChannels = "2";
            clsParameter1.AcCodecCodec = "libmp3lame";
            clsParameter1.ArFreq = "22050";
            clsParameter1.AbBitRate = "128k";
            clsParameter1.BBitRate = "512k";
            clsParameter1.RFps = "24";
            clsParameter1.VCodecCodec = "flv";

            clsParameter1.isAC = true;
            clsParameter1.isVn = true;
            //将定义的配置添加到这里
            arrlistParameters.Add(clsParameter1);


            clsParameter1 = new clsParameter();
            clsParameter1.FormatName = "mp3";
            clsParameter1.ParameterName = "mp3格式";
            clsParameter1.AcChannels = "2";
            clsParameter1.AcCodecCodec = "libmp3lame";
            clsParameter1.ArFreq = "22050";
            clsParameter1.AbBitRate = "128k";
            clsParameter1.isAC = true;
            clsParameter1.isVn = true;
            //将定义的配置添加到这里
            arrlistParameters.Add(clsParameter1);

            #endregion



        }

    }



}
